# tests/conftest.py - 测试配置
import pytest
import tempfile
import shutil
import os

@pytest.fixture(scope="session")
def temp_workspace():
    """创建临时工作空间"""
    temp_dir = tempfile.mkdtemp()
    original_cwd = os.getcwd()
    
    yield temp_dir
    
    os.chdir(original_cwd)
    shutil.rmtree(temp_dir, ignore_errors=True)

@pytest.fixture
def mock_streamlit_session():
    """模拟Streamlit会话状态"""
    class MockSessionState:
        def __init__(self):
            self.data = {}
        
        def get(self, key, default=None):
            return self.data.get(key, default)
        
        def __setitem__(self, key, value):
            self.data[key] = value
        
        def __getitem__(self, key):
            return self.data[key]
        
        def __contains__(self, key):
            return key in self.data
    
    return MockSessionState()